package com.study.zzedu.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.study.zzedu.R;
import com.study.zzedu.entity.YiDongModel;

import java.util.List;

public class YiDongAdapter extends RecyclerView.Adapter<YiDongAdapter.ViewHolder> {
    private List<YiDongModel> m;

    public class ViewHolder extends RecyclerView.ViewHolder
    {
        private TextView tvType,tvDate,tvDetail,tvStatus;
        public ViewHolder(View view){
            super(view);
            tvType = (TextView) view.findViewById(R.id.tv_yidong_type);
            tvDate = (TextView)  view.findViewById(R.id.tv_yidong_date);
            tvDetail = (TextView)  view.findViewById(R.id.tv_yidong_detail);
            tvStatus = (TextView)  view.findViewById(R.id.tv_yidong_status);
        }
    }

    public YiDongAdapter(List<YiDongModel> yiDongModel) {
        m = yiDongModel;
    }

    public ViewHolder onCreateViewHolder(ViewGroup parent, int Viewtype) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.yidong_item, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        if(m.size()<1)
            return;
        YiDongModel yiDongModel = m.get(position);
        holder.tvType. setText(yiDongModel.getType());
        holder.tvDate. setText(yiDongModel.getDate());
        holder.tvDetail. setText(yiDongModel.getDetail());
        holder.tvStatus. setText(yiDongModel.getStatus());
    }


    public int getItemCount() {
        return m.size();
    }
}